/*
* 文件：UnityXWindow.cs
* 作者：王阳
* 时间：2019-5-20
* 描述：UnityXWindow
*/

using UnityEditor;
using UnityEngine;

namespace UnityXEditor
{
    internal class UnityXWindow : EditorWindow
    {
        [MenuItem("Window/UnityX")]
        private static void OpenWindow()
        {
            UnityXWindow w = GetWindow<UnityXWindow>("UnityX");
            w.minSize = new Vector2(640, 640);
            w.Show();
        }
        private void Awake()
        {
            UnityXSettings.Save();
            UnityXSettings.Update();
            AssetDatabase.Refresh();
        }
        private void OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            float labelWidth = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth = 350;
            UnityXSettings.OnGUI();
            EditorGUIUtility.labelWidth = labelWidth;
            if (EditorGUI.EndChangeCheck())
            {
                UnityXSettings.Save();
            }
        }
        private void OnDestroy()
        {
            UnityXSettings.Save();
            UnityXSettings.Update();
            AssetDatabase.Refresh();
        }
    }
}
